// 需要1个cors 把资源共享出去
// npm install cors -


const express = require('express');
const cors = require('cors');
const server = express();
server.use('/api',cors())

// server.use('/api',(req,res,next)=>{
//     res.setHeader('Access-Control-Allow-Origin','*');
//     res.setHeader('Access-Control-Allow-Headers','PUT,POST,GET,DELETE,OPTIONS');
//     res.setHeader('Access-Control-Allow-Methods','X-Custom-Header,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization');
// })
const router = express.Router();
router.get('/api/a',(req,res)=>{

    
    res.send({
        code:1,
        message:'a success'
    })
})


router.get('/api/b',(req,res)=>{

    
    res.send({
        code:1,
        message:'b success'
    })
})

server.use(router);


server.listen(8081,()=>{
    console.log('server is running at http://');
})